<template>
  <div id="demo">
    <img src="./assets/logo.png">
    <h1>{{ message }}</h1>
    <button class="btn btn-warning" @click="getQuote()">取数据</button>
    <button class="btn btn-warning" @click="getVersion()">取api</button>
    <p>
      <router-link to="/demo">运动原型</router-link>
      <router-link to="/demo1">充电队长原型</router-link>
    </p>
    <!-- 路由匹配到的组件将渲染在这里 -->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'demo',
  data () {
    return {
      message: 'Welcome to vue_demo 小君 Hello world!'
    }
  },
  methods: {
    getQuote () {
      this.message = '恭喜你！你已完整地体验将本app的功能！'
    },
    getVersion () {
      this.$http.get('http://itstest.letscharge.cn/api/service_status.json').then(function (response) {
        console.log(response)
        this.message = JSON.stringify(response.data)
      })
    }
  },
  ready: function () {
    // `this` points to the vm instance
    // `this` 指向 vm 实例
    this.getVersion
    console.log('come on ready todo')
  }
  // ready: function () {
  //   this.getQuote
  // }
}
</script>

<style>
#demo {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
